#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
//读文件
int main()
{
    FILE *fp = fopen("test.txt", "r");
    if (fp == NULL)
    {
        perror("fopen");
        exit(1);
    }
    char buf[1024] = {0};
    while (1)
    {
        size_t s = fread(buf, 1, sizeof(buf) - 1, fp);
        if (s > 0)
        {
            buf[s] = 0;
            printf("%s\n", buf);
        }

        if (feof(fp))
        {
            printf("read end\n");
            break;
        }

        sleep(10);
    }
    fclose(fp);
    return 0;
}